<?php


namespace app\common\smsbao;

class Api
{
	public static function send($username, $apikey, $phone, $content)
	{
		try {
			$statusStr = [0 => "短信发送成功", -1 => "参数不全", -2 => "服务器空间不支持,请确认支持curl或者fsocket，联系您的空间商解决或者更换空间！", 30 => "APIKEY错误", 40 => "账号不存在", 41 => "余额不足", 42 => "帐户已过期", 43 => "IP地址限制", 50 => "内容含有敏感词", "" => "短信宝没有返回数据"];
			$smsapi = "https://api.smsbao.com/";
			$sendurl = $smsapi . "sms?u=" . $username . "&p=" . $apikey . "&m=" . $phone . "&c=" . urlencode($content);
			$result = get_curl($sendurl);
			if ($result === "0") {
				return true;
			} else {
				return $statusStr[$result];
			}
		} catch (\Exception $e) {
			return $e->getMessage();
		}
	}
}